package com.zr.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zr.service.HRServicedtp;
import com.zr.serviceImpl.HRServiceImpldtp;

import net.sf.json.JSONObject;
//注册新员工
public class AddEmplControllerdtp extends HttpServlet{
	HRServicedtp hr=new HRServiceImpldtp();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("utf-8");
		String ename=req.getParameter("ename");
		int eage=Integer.parseInt(req.getParameter("eage"));
		String esex=req.getParameter("esex");
		String eidcard=req.getParameter("eidcard");
		String enation=req.getParameter("enation");
		String eaddress=req.getParameter("eaddress");
		String ephone=req.getParameter("ephone");
		String eeducation=req.getParameter("eeducation");
		String eintime=req.getParameter("eintime");
		int did=Integer.parseInt(req.getParameter("did"))+1;
		String eposition=req.getParameter("eposition");
		String eremark=req.getParameter("eremark");
		int eid=hr.addUser(ename, eage, esex, enation, eidcard, eaddress, eeducation, eintime, eposition, eremark, did, ephone);
		JSONObject jobj=new JSONObject();
		jobj.put("eid", eid);
		PrintWriter pw=resp.getWriter();
		if(eid>0){
			pw.write(jobj.toString());
		}else{
			pw.write("false");
		}
	}
}
